import { Module, Global } from '@nestjs/common';
import { DbService } from './db.service';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
import WeaponEntity from './model/entity/weapon.entity';
import PersonEntity from './model/entity/person.entity';

const mysqlConnect: TypeOrmModuleOptions = {
  type: 'mysql',
  host: 'localhost',
  port: 3306,
  username: 'zzn',
  password: '12345678q',
  database: 'app_one',
  entities: [WeaponEntity, PersonEntity],
  synchronize: true,
};
const TypeORMConfig = TypeOrmModule.forRoot(mysqlConnect);
// PhotoEntity, WeaponEntity, PersonEntity

// @Global()
@Module({
  imports: [TypeORMConfig],
  providers: [DbService],
  exports: [DbService],
})
export class DbModule {}
